package com.example.sale.serviceImpl;

import com.example.sale.dao.PlanDAO;
import com.example.sale.entity.SaleChance;
import com.example.sale.entity.SalePlan;
import com.example.sale.service.PlanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

@Service("PlanServiceImpl")
public class PlanServiceImpl implements PlanService {

    @Autowired
    PlanDAO planDAO;

    @Override
    public List queryDataAll() {
        List list = planDAO.queryDataAll();
       return list;
    }

    @Override
    public List<Map> queryData(String id) throws Exception {
        List data = planDAO.queryData(id);
        return data;
    }

    @Override
    public SalePlan queryById(String id) {
        SalePlan data = planDAO.queryPlanById(id);
        return data;
    }

    @Override
    public List<SalePlan> queryByCusId(String id){
        List<SalePlan> dataList = planDAO.queryByCusId(id);
        return dataList;
    }

    @Override
    @Transactional
    public void savePlan(SalePlan salePlan) {
        planDAO.savePlan(salePlan);
    }

    @Override
    @Transactional     //-->出错则事务回滚，不会添加到数据库(不会处理请求)
    public void deleteInfo(String id) {
        planDAO.deleteInfo(id);
    }

    @Override
    @Transactional     //-->出错则事务回滚，不会添加到数据库(不会处理请求)
    public void updateInfo(SalePlan salePlan) {
        planDAO.updateInfo(salePlan);
    }

    @Override
    @Transactional     //-->出错则事务回滚，不会添加到数据库(不会处理请求)
    public void saveInfo(SaleChance saleChance, HttpServletRequest request) {
        planDAO.saveInfo(saleChance,request);
    }
}





